import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../pages/Home'
import About from '../pages/About'
import News from '../pages/News'
import Message from '../pages/Message'
import Detail from '../pages/Detail'


Vue.use(VueRouter)

//创建一个路由器，管理着整个应用中的所有路由
const router = new VueRouter({
	mode:'history',//配置路由的工作模式，默认是hash模式
	routes:[
		{
			path:'/home',
			component:Home,
			children:[
				{
					path:'news', //二级路由的配置中，路径一定不要加/
					component:News
				},
				{
					path:'message',
					component:Message,
					children:[
						{
							path:'detail/:id/:title/:content', //params参数必须声明接收
							component:Detail
						}
					]
				}
			]
		},
		{
			path:'/about',
			component:About
		}
	]
})

//暴露路由器
export default router